import QtQuick 2.0

Item {
    property int duration: 3000;

    id: root;

    Rectangle {
        id: rect1;
        color: "#f0f0f0";
        border.color: Qt.lighter(color);
        width: parent.width / 2;
        anchors.left: parent.left;
        anchors.top: parent.top;
        anchors.bottom: parent.bottom;

        ClickableImageV3 {
            id: ufo1;
            x: 20; y: 120;
            source: "rec/rec/image/ufo.png";

            onClicked: {
                anima1.restart();
            }
        }

        //平行动画
        ParallelAnimation {
            id: anima1;

            NumberAnimation {
                target: ufo1;
                property: "y";
                to: 20;
                duration: root.duration;
            }

            NumberAnimation {
                target: ufo1;
                property: "x";
                to: 160;
                duration: root.duration;
            }
        }
    }

    Rectangle {
        id: rect2;
        color: "#f0f0f0";
        border.color: Qt.lighter(color);
        anchors.left: rect1.right;
        anchors.leftMargin: 5;
        anchors.top: parent.top;
        anchors.bottom: parent.bottom;
        anchors.right: parent.right;

        ClickableImageV3 {
            id: ufo2;
            x: 20; y: 120;
            source: "rec/rec/image/ufo.png";

            onClicked: {
                anima2.restart();
            }
        }

        //连续动画
        SequentialAnimation {
            id: anima2;

            NumberAnimation {
                target: ufo2;
                property: "y";
                to: 20;
                duration: root.duration*0.6;
            }

            NumberAnimation {
                target: ufo2;
                property: "x";
                to: 160;
                duration: root.duration*0.4;
            }
        }
    }
}
